package com.first.xiinn.dao.impl;

import java.util.List;

import com.first.core.dao.impl.BaseDaoImpl;
import com.first.xiinn.dao.BookCatalogDao;
import com.first.xiinn.model.BookCatalog;

public class BookCatalogDaoImpl extends BaseDaoImpl<BookCatalog> implements
		BookCatalogDao {

	public BookCatalogDaoImpl() {
		super(BookCatalog.class);
	}

	public List<BookCatalog> findByParentId(String parentId) {
		String hql = "from BookCatalog b where b.parentId=?";
		Object[] params = { parentId };
		return findByHql(hql, params);
	}

	public BookCatalog get(String bookCalalogId) {
		String hql = "from BookCatalog b where b.catalogId=?";
		Object[] params = { bookCalalogId };
		List<BookCatalog>  BookCatalogs = findByHql(hql, params);
		if(BookCatalogs.size() >0 ){
			return BookCatalogs.get(0);
		}else{
			return null;
		}
	}
	
	public List search(String bookid) {
		String hql ="from BookCatalog c where c.bookid=?";
		Object[] params = {bookid};
		List lsit = findByHql(hql, params);
		if(!lsit.isEmpty()){
			return lsit;
		}
		return null;
	}
}
